package com.lg.distributed.transaction.message.scheduled;

import com.lg.distributed.transaction.message.retry.ResendProcess;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author by Mr. Li 2020/12/12 16:41
 */
@Component
@EnableScheduling
@Slf4j
public class MessageScheduledSend {

    @Autowired
    private ResendProcess resendProcess;

    /**
     * 每天0点 对所有没有 retry 次数 大于5 进行一次 重发
     * 失败的进行告警通知
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void FinallyTryAgain() throws Exception {
        log.info("系统进行消息的最后重试=====>");
        resendProcess.finallyResendReadyMsg();
    }
}
